package com.oscar.ehome.view.pageview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.oscar.ehome.R;
import com.oscar.ehome.base.C;
import com.oscar.ehome.bean.pagebean.StudyBean;
import com.oscar.ehome.bean.pagebean.YeJiListBean;
import com.oscar.ehome.bean.setbean.LearnHistoryBean;
import com.oscar.ehome.provider.gildeimage.GildeUtils;

import java.util.List;

/**
 * Created by juxing
 * author: SunHaoZhao
 * date: On 2018/4/18
 */

public class YeJiListAdapter extends BaseAdapter {

    private List<YeJiListBean.yonghu> list;

    private LayoutInflater mInflater;
    private Context mContext = null;
    int bean = 0;
    int size = 0;

    public YeJiListAdapter(Context context, List<YeJiListBean.yonghu> list, int bean) {
        this.mContext = context;
        this.list = list;
        this.bean = bean;
        mInflater = LayoutInflater.from(context);
    }

    public YeJiListAdapter(Context context, List<YeJiListBean.yonghu> lists) {
        this.mContext = context;
        this.list = lists;
        mInflater = LayoutInflater.from(context);
    }

    public void setLists(List<YeJiListBean.yonghu> list, int bean) {
        this.list = list;
        this.bean = bean;
        notifyDataSetChanged();
    }

    public void setLists(List<YeJiListBean.yonghu> lists) {
        this.list = lists;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {

        size = list.size();

        return size;
    }

    @Override
    public Object getItem(int position) {

        return list.get(position);

    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        YeJiListAdapter.ViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.yejichaxunlistitem, null);
            holder = new YeJiListAdapter.ViewHolder();
            holder.name_text = (TextView) convertView.findViewById(R.id.name_text);
            holder.xinzengyouxiao_text = (TextView) convertView.findViewById(R.id.xinzengyouxiao_text);
            holder.touxiang_img =  convertView.findViewById(R.id.touxiang_img);
            holder.xingbie_img = (ImageView) convertView.findViewById(R.id.xingbie_img);
            holder.tuanduiitem=convertView.findViewById(R.id.tuanduiitem);
            holder.dangyueyushou_text = (TextView) convertView.findViewById(R.id.dangyueyushou_text);
            holder.nianduyushou_text = (TextView) convertView.findViewById(R.id.nianduyushou_text);
            convertView.setTag(holder); //
        } else {
            holder = (YeJiListAdapter.ViewHolder) convertView.getTag(); //
        }
        if(position==0){
           holder.tuanduiitem.setVisibility(View.GONE);
        }else{
            holder.name_text.setText(list.get(position).getUser().getName());
            GildeUtils.loadUrlImage4(C.qiniu_ip + list.get(position).getUser().getPhoto(), holder.touxiang_img, mContext);
            if (list.get(position).getUser().getSex().equals("男")) {
                holder.xingbie_img.setImageResource(R.mipmap.nan);
            } else {
                holder.xingbie_img.setImageResource(R.mipmap.nv);
            }
            holder.xinzengyouxiao_text.setText(list.get(position).getValue7()+"人");
            holder.dangyueyushou_text.setText(list.get(position).getValue2()+"元");
            holder.nianduyushou_text.setText(list.get(position).getValue4()+"万元");

        }

        return convertView;
    }

    class ViewHolder {
        TextView name_text;//标题
        ImageView touxiang_img;//touxiang
        ImageView xingbie_img;//xingbie
        TextView xinzengyouxiao_text;//时间
        TextView dangyueyushou_text;//
        TextView nianduyushou_text;
       LinearLayout tuanduiitem;
    }

}
